package com.lc.sell.controller;


import com.lc.sell.dto.UserDTO;
import com.lc.sell.entity.User;
import com.lc.sell.service.UserService;
import com.lc.sell.vo.ResultVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙晨
 * @since 2022-02-15 02:21:17
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("findUser")
    @ApiOperation("用户登录")
    public ResultVo findUserByPhoneAndPassword(HttpServletRequest request, @RequestBody UserDTO userDTO){
        return userService.findUserByPhoneAndPassword(request,userDTO.getPhone(), userDTO.getPassword());
    }

    @ApiOperation(value = "修改用户信息")
    @PostMapping("upd")
    public ResultVo updateUser(@RequestBody User user){
        return userService.updUser(user);
    }

    @ApiOperation(value = "新增用户信息")
    @PostMapping("add")
    public ResultVo addUser(@RequestBody User user){
        return userService.insertIntoUser(user);
    }


    @ApiOperation(value = "查询用户金额")
    @GetMapping("sel")
    public ResultVo selUserManey(@RequestParam String userid){
        return userService.selUserManey(userid);
    }

    @ApiOperation(value = "查询用户信息")
    @GetMapping("oneUser")
    public ResultVo selOneUser(@RequestParam String userid){
        return userService.selectOneUser(userid);
    }

}
